package com.hl.security;

import com.hl.domain.LiliShopMember;
import com.hl.mapper.LiliShopMemberMapper;
import com.ruoyi.system.api.RemoteLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;

import java.util.Set;

@Service
public class UserDetailServiceImpl implements UserDetailsService {

    @Autowired
    private LiliShopMemberMapper liliShopMemberMapper;
    @Autowired
    private RemoteLogService remoteLogService;
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        LiliShopMember member = liliShopMemberMapper.selectLiliShopMemberByMemberName(username);
        LoginUser user = null;
        long id = 2;
        if (member != null) {
            Set<String> perm = remoteLogService.cha(id);
            System.out.println("权限" + perm);
            user = new LoginUser(member, perm);
        }
        return user;
    }
}
